import request from '@/utils/request'

// 分页获取角色列表
export const getRoleListAPI = (auery) => {
  return request({
    method: 'get',
    url: '/sys/role',
    params: auery
  })
}

// 新增角色
export const postRoleAPI = (roleForm) => {
  return request({
    method: 'post',
    url: '/sys/role',
    data: roleForm
  })
}

// 编辑角色
export const putRoleAPI = (editRow) => {
  return request({
    method: 'put',
    url: `/sys/role/${editRow.id}`,
    data: editRow
  })
}

// 删除角色
export const delRoleAPI = (id) => {
  return request({
    method: 'delete',
    url: `/sys/role/${id}`
  })
}

// 获取所有可用的角色列表
export const getEnabledRoleAPI = () => {
  return request({
    method: 'get',
    url: '/sys/role/list/enabled'
  })
}

// 获取角色详情
export const getRoleDetailAPI = (id) => {
  return request({
    method: 'get',
    url: `/sys/role/${id}`
  })
}

// 给角色分配权限
export const assignPermAPI = (id, permIds) => {
  return request({
    method: 'put',
    url: '/sys/role/assignPrem',
    data: {
      id,
      permIds
    }
  })
}
